<?php
namespace app\html\controller;
use app\html\model\Channel;
use think\Request;
use think\Db;
class Index extends Base
{
    public function index()
    {
        $mark="index";
        // 公司介绍
        $about=db("cms_page")->find(1);
        $about['content']=html_entity_decode($about['content']);
        $about['cname']=db("channel")->where("id=".$about['cid'])->value("name");
        $where['status']=1;    
        $where['is_home']=1;
        $news=db("cms_news")->where($where)->order("sort asc ,id desc")->limit(7)->select();
        for ($i=0; $i < count($news); $i++) { 
            $news[$i]['cname']=db("channel")->where("id=".$news[$i]['cid'])->value("name");
        }
        // 案例
        $case=db("cms_case")->where($where)->order("sort asc ,id desc")->limit(12)->select();
        for ($i=0; $i < count($case); $i++) { 
            $case[$i]['cname']=db("channel")->where("id=".$case[$i]['cid'])->value("name");
            // $listnews[$i]['annexes']=db("filex")->where("id=".$listnews[$i]['thumb'])->value("thumb");
        }
        // 公司产品
        $procate=db("channel")->where("pid=9 and status=1")->order("sort asc,id asc")->limit(2)->select();
        $limit="4";
        $prowhere['cid']=$procate[0]['id'];
        $prowhere['status']=1;
        $prowhere['is_home']=1;
        $product=db("cms_product")->where($prowhere)->order("sort asc , id desc")->limit($limit)->select();
        for ($i=0; $i < count($product); $i++) { 
            $product[$i]['cname']=db("channel")->where("id=".$product[$i]['cid'])->value("name");
            // $product[$i]['annexes']=db("filex")->where("id=".$product[$i]['thumb'])->value("thumb");
        }
        
        // print_r($promess);exit;

        $partner=db("cms_partner")->where($where)->order("sort asc ,id desc")->limit(4)->select();    
        
        $download=db("cms_download")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $honor=db("cms_honor")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $teamer=db("cms_teamer")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $course=db("cms_course")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $article=db("cms_article")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $album=db("cms_album")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $zszc=db("cms_article")->where($where)->order("sort asc ,id desc")->limit(3)->select();
        $topic=db("cms_topic")->where($where)->order("sort asc ,id desc")->limit(10)->select();
        $this->assign("about",$about);
        $this->assign("download",$download);
        $this->assign("partner",$partner);
        $this->assign("ad",$ad);
        $this->assign("procate",$procate);
        $this->assign("product",$product);
        $this->assign("news",$news);
        $this->assign("case",$case);
        $this->assign("honor",$honor);
        $this->assign("teamer",$teamer);
        $this->assign("course",$course);
        $this->assign("article",$article);
        $this->assign("banner",$banner);
        $this->assign("album",$album);
        $this->assign("zszc",$zszc);
        $this->assign("topic",$topic);
		return view($mark);
    }
    public function getPrut()
    {
        $cid=request()->param('cid'); 
        $limit="4";
        $prowhere['cid']=$cid;
        $prowhere['status']=1;
        $prowhere['is_home']=1;
        $product=db("cms_product")->where($prowhere)->order("sort asc , id desc")->limit($limit)->select();
        for ($i=0; $i < count($product); $i++) { 
            $product[$i]['cname']=db("channel")->where("id=".$product[$i]['cid'])->value("name");
            // $product[$i]['annexes']=db("filex")->where("id=".$product[$i]['thumb'])->value("thumb");
        }
        // print_r($product);exit;
        $this->assign("product",$product);
        return view('getPrut');
    }
}
